!
! Copyright (C) 2000-2013 A. Marini and the YAMBO team 
!              https://code.google.com/p/rocinante.org
! 
! This file is distributed under the terms of the GNU 
! General Public License. You can redistribute it and/or 
! modify it under the terms of the GNU General Public 
! License as published by the Free Software Foundation; 
! either version 2, or (at your option) any later version.
!
! This program is distributed in the hope that it will 
! be useful, but WITHOUT ANY WARRANTY; without even the 
! implied warranty of MERCHANTABILITY or FITNESS FOR A 
! PARTICULAR PURPOSE.  See the GNU General Public License 
! for more details.
!
! You should have received a copy of the GNU General Public 
! License along with this program; if not, write to the Free 
! Software Foundation, Inc., 59 Temple Place - Suite 330,Boston, 
! MA 02111-1307, USA or visit http://www.gnu.org/copyleft/gpl.txt.
!
subroutine ypp_init_load(defs)
 !
 use it_m,          ONLY:it,initdefs,E_unit,G_unit,V_general,&
&                        Time_unit,Bfield_unit,Efield_unit,V_real_time
 use wave_func,     ONLY:wf_ng
 use electrons,     ONLY:n_spinor
 use YPP
#if defined _YPP_SURF
 use bulkeps,              ONLY: init_bulk
 use convolute,            ONLY: init_convolute
 use eels_kinematics,      ONLY: init_kinematics
 use model_loss_function,  ONLY: init_loss_function
 use surface_geometry,     ONLY: init_surface
 use eels_detector,        ONLY: init_detector
#endif
 implicit none
 type(initdefs)::defs
 !
 ! RunLevels
 !
 call it('r',defs,'bzgrids',   '[R] BZ Grid') 
 call it('r',defs,'K_grid',    '[R] K-grid analysis') 
 call it('r',defs,'Q_grid',    '[R] Q-grid analysis') 
 call it('r',defs,'dos',       '[R] DOS')
 !
 !
 call it('r',defs,'High_Symm', '[R] High_Symmetry points and paths') 
 call it('r',defs,'excitons',  '[R] Excitons')
 call it('r',defs,'electrons', '[R] Electrons (and holes)')
 call it('r',defs,'freehole',  '[R] Free hole position')
 call it('r',defs,'amplitude', '[R] Amplitude')
 call it('r',defs,'plot',         '[R] Plot')
 call it('r',defs,'density',      '[R] Density')
 call it('r',defs,'wannier',      '[R] Wannier 90 I/O')
 call it('r',defs,'bnds',        '[R] Bands')
 call it('r',defs,'wavefunction', '[R] Wavefunction')
#if defined _YPP_ELPH
 call it('r',defs,'eliashberg',   '[R] Eliashberg')
 call it('r',defs,'phonons',      '[R] Phonons')
 call it('r',defs,'gkkp',         '[R] Electron-Phonon databases')
#endif
#if defined _YPP_SURF
 call it('r',defs,'surf',    '[R] Surface spectroscopy postprocessor')
 call it('r',defs,'ras',     '[R] RAS spectra generator')
 call it('r',defs,'reels',   '[R] REELS spectra generator')
 call it('r',defs,'loc',     '[R] State localizer')
 call it('r',defs,'trans',   '[R] Transition analyzer')
#endif
 call QP_ctl_load(defs,3)
 call it('r',defs,'spin','[R] Spin')
 call it('r',defs,'magnetization','[R] Magnetization')
 call it('r',defs,'bzrim',   '[R] BZ energy RIM analyzer')
 call it('r',defs,'qpdb',    '[R] Quasi-particle database manager')
 call it('r',defs,'bxsf'   , '[R] Read BXSF files generated by Wannier90')    
 !
 call it('r',defs,'fixsyms', '[R] Reduce Symmetries')
 !
 !
 ! DOS
 !
 call it(defs,'DOS_broad', 'Broadening of the DOS',dos_broadening,E_unit) 
 call it(defs,'DOS_bands', 'DOS bands',dos_bands) 
 call it(defs,'DOSERange', 'Energy range',dos_E_range,unit=E_unit,verb_level=V_general) 
 call it(defs,'DOSESteps', 'Energy steps',dos_E_steps,verb_level=V_general) 
 !
 ! BANDS
 !
 call it(defs,'BANDS_steps', 'Number of divisions',BANDS_steps) 
 call it(defs,'BANDS_range', 'Bands Range',BANDS_range) 
 call it(defs,'BKpts','Bands circuit',Kgw_1)
 !
 ! Wannier interface
 !
 call it(defs,'Seed','Seed name',seed_name)
 call it(defs,'WriteAMU','What to write (A, M, U)',what_to_write)
 !
 ! BZ grids
 !
 call it(defs,'cooIn','Points coordinates (in) cc/rlu/iku/alat',coo_in)
 call it(defs,'cooOut','Points coordinates (out) cc/rlu/iku/alat',coo_out)
 call it(defs,'GWKpts','GW K-point grid',Kgw_1)
 call it(defs,'Qpts',  'Q-point grid',   Kgw_1)
 call it(defs,'KShift1','K-grid shift vector[1] ',q_shift(1,:))
 call it(defs,'KShift2','K-grid shift vector[2] ',q_shift(2,:))
 call it(defs,'KShift3','K-grid shift vector[3] ',q_shift(3,:))
 !
 !
 call it('f',defs,'NoWeights',    ' Do not print points weight') 
 call it('f',defs,'ForceUserPts', ' Do not check the correcteness of the user points') 
 call it('f',defs,'ListPts',      ' List the internal q/k points also in the parser format') 
 call it('f',defs,'ExpandPts',    ' Expand the internal q/k points in the BZ') 
 !
 ! EXC WF
 !
 call it(defs,'FFTGvecs','[FFT] Plane-waves',wf_ng,G_unit)
 call it(defs,'Degen_Step', 'Maximum energy separation of two degenerate states',&
&                           deg_energy,E_unit)
 call it(defs,'MinWeight', 'Print transitions with weight => MinWeight',min_weight,verb_level=V_general)
 call it(defs,'States','Index of the BS state(s)',state_ctl)
 call it(defs,'Cells', 'Number of cell repetitions (even or 1)',ncell)
 call it(defs,'Hole', '[cc] Hole position in unit cell',r_hole)
 call it(defs,'WFMult', 'Multiplication factor to the excitonic wavefunction',WF_multiplier,verb_level=V_general)
 !
 !
 ! PLOT
 !
 ! p_dir: plot cut in the a1,a2,a3 basis
 ! 
 ! p_format: (c)ube/(g)nuplot/(x)crysden
 !
 call it(defs,'Format', 'Output format [(c)ube/(g)nuplot/(x)crysden]',p_format)
 call it(defs,'Direction', '[rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D',p_dir)
 call it(defs,'MagDir', 'Magnetization component',mag_dir)
#if defined _YPP_ELPH
 !
 !EL-PH
 !
 call it(defs,'DBsPATH',  'Path to the PW el-ph databases',elph_dbs_path)
 call it(defs,'PHfreqF',  'PWscf format file containing the phonon frequencies',ph_freqs_file)
 call it(defs,'EfGbroad', 'Fermi surface broadening (Gamma)',elph_gamma_broad,E_unit)
 call it(defs,'PhBroad','Phonon broadening (Eliashberg & DOS)',ph_broad,E_unit)
 call it(defs,'EEfermi','External Fermi Level (Eliashberg)',elph_Ef,E_unit)
 call it(defs,'PhStps', 'Energy steps',elph_steps)
 call it('f',defs,'GkkpExpand','Expand the gkkp in the whole BZ')
 !
#endif
#if defined _YPP_SURF
 !
 ! RAS/REELS
 !
 call it(defs,'XData',     'Filename of q[x] data',xdata)
 call it(defs,'YData',     'Filename of q[y] data',ydata)
 call it(defs,'ZData',     'Filename of q[z] data',zdata)
 call it(defs,'SrfShift',  'Shift of surface spectra',sshift,E_unit)
 call it(defs,'DataType',  'Form of epsilon/alpha data on input [eps/a_t/a_r][23/45]',datatype)
 call it(defs,'d_cell',    'Perpendicular component of cell',d_cellin)
 call init_bulk(defs)
 call init_convolute(defs)
 !
 ! Analysis
 !
 call it(defs,'NormDir',   'Index of surface normal (1/2/3)',normdir)
 call it(defs,'LowerLim',  'Lower limit of localization box (frac)',lowerlim)
 call it(defs,'UpperLim',  'Upper limit of localization box (frac)',upperlim)
 call it(defs,'NGLoc',     'G-vectors for localization sum',ngloc)
 call it(defs,'LbndRnge',  'Loc bands range',loc_bands)
 call it(defs,'KptRange',  'Loc kpts range',loc_kpts)
 call it('f',defs,'WrtLocDB','Create localization database')
 !
 call it(defs,'EcvMin',  'Lower limit of transition window',Ecv_min,E_unit)
 call it(defs,'EcvMax',  'Upper limit of transition window',Ecv_max,E_unit)
 call it(defs,'PolDir',  'Index of polarization direction',idir)
 call it(defs,'qdir'  ,  '[cc] X-polarization direction', qdir )
 call init_kinematics(defs)
 call init_loss_function(defs)
 call init_surface(defs)
 call init_detector(defs)
 !
#endif
 !
 !BZ E RIM
 !
 call it(defs,'BZ_RIM_Nk','BZ Random Integration points',BZ_RIM_nkpts)
 call it(defs,'BZ_RIM_path','Path to the SAVE folder with the RIM DB1',BZ_RIM_path)
 !
 ! Wannier bands
 !
 call it(defs,'W90_fname','Name of w90 input file',w90_fname)
 call it(defs,'WannBnds','Range of interpolated bands, internally start from 1',wannier_bands)
 call it(defs,'DgridOrd','Order of interpolation with double grid',ord_dgrid_ipol)
 !
 !
 ! Remove Simmetries
 !
 if(n_spinor==2) call it('f',defs,'ExpandSymm' , 'Add inv and magnetic symms if possible')
 call it('f',defs,'RmAllSymm' , 'Remove all symmetries')
 call it('f',defs,'RmTimeRev' , 'Remove Time Reversal')
 !
 !
end subroutine
